Imports Infragistics
Imports Infragistics.Win.UltraWinGrid
Imports System.Runtime.InteropServices.Marshal
Public Class Form2
    Dim obj As ObjUtils = New ObjUtils
    'Dim cbo3 As UltraCombo
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'GppDataSet.tbl_thuoc_dkbaoquan' table. You can move, or remove it, as needed.
        Me.Tbl_thuoc_dkbaoquanTableAdapter.Fill(Me.GppDataSet.tbl_thuoc_dkbaoquan)
        'TODO: This line of code loads data into the 'GppDataSet.tbl_thuoc_hoatchat' table. You can move, or remove it, as needed.
        Me.Tbl_thuoc_hoatchatTableAdapter.Fill(Me.GppDataSet.tbl_thuoc_hoatchat)
        'TODO: This line of code loads data into the 'SampleDataSet.tbl_xuat_chitiet' table. You can move, or remove it, as needed.
        Me.Tbl_xuat_chitietTableAdapter.Fill(Me.SampleDataSet.tbl_xuat_chitiet)
        Me.Tbl_hanghoaTableAdapter.Fill(Me.SampleDataSet.tbl_hanghoa)
        obj.addObject(New ObjUtils(Me.Tbl_hanghoaUltraGrid, ObjUtils._None))
        obj.addObject(New ObjUtils(Me.Tbl_hanghoaUltraCombo, ObjUtils._None))
        obj.addObject(New ObjUtils(Me.UltraCombo2, ObjUtils._None))
        'obj.addObject(New ObjUtils(Me.UltraCombo1, ObjUtils._None))
        Me.UltraCombo2.DataSource = Me.Tbl_hanghoaBindingSource
        obj.setGiaoDien()

        'MakeEnterActLikeTab(Me.Tbl_hanghoaUltraGrid)
        Me.cbo3 = New Infragistics.Win.UltraWinGrid.UltraCombo
        CType(Me.cbo3, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.Controls.Add(Me.cbo3)
        Me.cbo3.Name = "UltraCombo2"
        Me.cbo3.PreferredDropDownSize = New System.Drawing.Size(0, 0)
        Me.cbo3.Size = New System.Drawing.Size(330, 146)
        Me.cbo3.TabIndex = 100
        Me.cbo3.Text = "UltraCombo2"
        Me.cbo3.CheckedListSettings.CheckStateMember = ""
    End Sub
    Private Sub MakeEnterActLikeTab(ByVal Grid As Infragistics.Win.UltraWinGrid.UltraGrid)
        Dim newKam As Infragistics.Win.UltraWinGrid.GridKeyActionMapping
        For Each ugkam As Infragistics.Win.UltraWinGrid.GridKeyActionMapping In Grid.KeyActionMappings
            If ugkam.KeyCode = Keys.Tab Then
                newKam = New Infragistics.Win.UltraWinGrid.GridKeyActionMapping(Keys.Enter, ugkam.ActionCode, ugkam.StateDisallowed, ugkam.StateRequired, ugkam.SpecialKeysDisallowed, ugkam.SpecialKeysRequired)
                Grid.KeyActionMappings.Add(newKam)
            End If
        Next
    End Sub
    Private Sub Tbl_hanghoaUltraGrid_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)

    End Sub


    Private Sub Tbl_hanghoaUltraDropDown_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tbl_hanghoaUltraDropDown.TextChanged

    End Sub

    Private Sub Tbl_hanghoaUltraGrid_KeyDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Tbl_hanghoaUltraGrid.KeyDown
        'M_Ultragrid.getGridKeyDown(e, Me.Tbl_hanghoaUltraGrid)
    End Sub

    Private Sub Tbl_hanghoaUltraGrid_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles Tbl_hanghoaUltraGrid.InitializeLayout


    End Sub
    'Public Sub ExportToExcel(ByVal DS_MyDataset As DataSet)

    '    'The full path where the excel file will be stored

    '    Dim strFileName As String = AppDomain.CurrentDomain.BaseDirectory.Replace("/", "\")
    '    strFileName = strFileName & "\MyExcelFile" & System.DateTime.Now.Ticks.ToString() & ".xls"

    '    Dim objExcel As Excel.Application
    '    Dim objBooks As Excel.Workbooks, objBook As Excel.Workbook
    '    Dim objSheets As Excel.Sheets, objSheet As Excel.Worksheet
    '    Dim objRange As Excel.Range

    '    Try
    '        'Creating a new object of the Excel application object
    '        objExcel = New Excel.Application
    '        'Hiding the Excel application
    '        objExcel.Visible = False
    '        'Hiding all the alert messages occurring during the process
    '        objExcel.DisplayAlerts = False

    '        'Adding a collection of Workbooks to the Excel object
    '        objBook = CType(objExcel.Workbooks.Add(), Excel.Workbook)

    '        'Saving the Workbook as a normal workbook format.
    '        objBook.SaveAs(strFileName, Excel.XlFileFormat.xlWorkbookNormal)

    '        'Getting the collection of workbooks in an object
    '        objBooks = objExcel.Workbooks

    '        'Get the reference to the first sheet in the workbook collection in a variable
    '        objSheet = CType(objBooks(1).objSheets.Item(1), Excel.Worksheet)
    '        'Optionally name the worksheet
    '        objSheet.Name = "First Sheet"
    '        'You can even set the font attributes of a range of cells in the sheet. Here we have set the fonts to bold.
    '        objSheet.Range("A1", "Z1").Font.Bold = True

    '        'Get the cells collection of the sheet in a variable, to write the data.
    '        objRange = objSheet.Cells

    '        'Calling the function to write the dataset data in the cells of the first sheet.
    '        WriteData(DS_MyDataset.Tables(0), objCells)

    '        'Setting the width of the specified range of cells so as to absolutely fit the written data.
    '        objSheet.Range("A1", "Z1").EntireColumn.AutoFit()
    '        'Saving the worksheet.
    '        objSheet.SaveAs(strFileName)

    '        objBook = objBooks.Item(1)
    '        objSheets = objBook.Worksheets
    '        objSheet = CType(objSheets.Item(2), Excel.Worksheet)
    '        objSheet.Name = "Second Sheet"
    '        'Setting the color of the specified range of cells to Red (ColorIndex 3 denoted Red color)
    '        objSheet.Range("A1", "Z1").Font.ColorIndex = 3

    '        objRange = objSheet.Cells
    '        WriteData(DS_MyDataset.Tables(1), objCells)
    '        objSheet.Range("A1", "Z1").EntireColumn.AutoFit()

    '        objSheet.SaveAs(strFileName)

    '    Catch ex As Exception
    '        Response.Write(ex.Message)
    '    Finally
    '        'Close the Excel application
    '        objExcel.Quit()

    '        'Release all the COM objects so as to free the memory
    '        ReleaseComObject(objRange)
    '        ReleaseComObject(objSheet)
    '        ReleaseComObject(objSheets)
    '        ReleaseComObject(objBook)
    '        ReleaseComObject(objBooks)
    '        ReleaseComObject(objExcel)

    '        'Set the all the objects for the Garbage collector to collect them.
    '        objExcel = Nothing
    '        objBooks = Nothing
    '        objBook = Nothing
    '        objSheets = Nothing
    '        objSheet = Nothing
    '        objRange = Nothing

    '        'Specifically call the garbage collector.
    '        System.GC.Collect()
    '    End Try
    'End Sub

    'Private Function WriteData(ByVal DT_DataTable As DataTable, ByVal objCells As Excel.Range) As String
    '    Dim iRow As Integer, iCol As Integer

    '    'Traverse through the DataTable columns to write the headers on the first row of the excel sheet.
    '    For iCol = 0 To DT_DataTable.Columns.Count - 1
    '        objCells(1, iCol + 1) = DT_DataTable.Columns(iCol).ToString
    '    Next

    '    'Traverse through the rows and columns of the datatable to write the data in the sheet.
    '    For iRow = 0 To DT_DataTable.Rows.Count - 1
    '        For iCol = 0 To DT_DataTable.Columns.Count - 1
    '            objCells(iRow + 2, iCol + 1) = DT_DataTable.Rows(iRow)(iCol)
    '        Next
    '    Next
    'End Function
End Class
